package light.head.dao.site;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import light.head.constant.Parm;
import light.head.enm.RESULT;
import light.head.framework.base.BaseDAO;
import light.head.framework.entity.PageBean;
import light.head.model.SettledApply;

import org.springframework.stereotype.Service;
/**
 * 商家入驻申请
 */
@Service
public class SettledApplyDAO extends BaseDAO<SettledApply, Serializable>{
	
	public RESULT findByMap(Map<String, String> map, PageBean pageBean) {
		StringBuffer hql = new StringBuffer("FROM SettledApply sa WHERE sa.deleted = 0");
		List<Object> list = null;
		if (map != null) {
			list = new ArrayList<Object>();
			String name = map.get(Parm.NAME);
			String status = map.get(Parm.STATUS);
			if (name != "" && isNotNull(name)) {
				hql.append(" AND sa.name = ? ");
				list.add("%"+ name +"%");
			}
			if(status !=null && isNotNull(status)){
				hql.append(" AND sa.status = ?");
				list.add(Boolean.parseBoolean(status));
			}
			
		}
		hql.append(" ORDER BY sa.code");

		return findToPageBean(hql.toString(), pageBean, list);
	}
}
